package Registry;

import java.rmi.Naming;
import java.rmi.RMISecurityManager;
import java.rmi.RemoteException;

public class Main {

	public static void main(String[] args) throws RemoteException {		
		try {
	        int port = 1099;
	        
	        if (args.length > 0)
	        	port =  Integer.valueOf(args[0]);
	        
			System.out.println("[REGISTRY] Loading..");
			//System.setProperty("java.security.policy", "Policies/registry.policy");


			if(System.getSecurityManager() == null) {
				System.setSecurityManager(new RMISecurityManager());
			}
			
			RegistryImplementation r = new RegistryImplementation(port);
			Naming.bind("RegistryImplementation", r);
			
			System.out.println("[REGISTRY] Loaded, registry can be used now.");

			while (true) {}
		} catch (Exception e) {
			e.printStackTrace();
		} 
	}
}
